#include<stdio.h>
#include<stdlib.h>
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
}
void reorder(int a[], int length)  
{  
	int low=0,high=length-1;
    while(low<high){
        while(a[low]<0 && low<high) low++;
        while(a[high]>0 && low<high) high--;
        swap(a[low],a[high]);
    }
}  
int main(){
    int a[]={1,2,3,-1,4,-2};
    reorder(a,6);
    for(auto num:a){
        printf("%d ",num);
    }
    return 0;
}